package com.wing.order.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * 出/入库作业单记录
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("ord_inventory_job")
public class InventoryJob extends BaseEntity<InventoryJob> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum InoutType implements IEnum<Integer> {

        /**
        * 入库
        */
        in(1,"入库"),
        /**
        * 出库
        */
        out(2,"出库");

        private int code;
        private String desc;

        InoutType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    public enum TransportType implements IEnum<Integer> {

        /**
        * 快递运输
        */
        logistics(0,"物流运输"),
        /**
        * 快递运输
        */
        express(1,"快递运输"),
        /**
        * 自行运输
        */
        self(2,"自行运输");

        private int code;
        private String desc;

        TransportType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
        @JsonCreator
        public static TransportType jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (TransportType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 出/入库作业单编号
     */
    private String code;

    /**
     * 出入库计划id
     */
    private Long planId;

    /**
     * 出入库类型
     */
    private InoutType inoutType;

    /**
    * 出入库类型描述
    */
    @TableField(exist = false)
    private String inoutTypeDesc;

    public String getInoutTypeDesc() {
        return inoutType == null ? null : inoutType.getDesc();
    }

    /**
     * 发货商
     */
    private String customerName;

    /**
     * 客户联系人
     */
    private String customerConcat;

    /**
     * 联系人电话
     */
    private String customerMoble;

    /**
     * 车牌号
     */
    private String carNo;

    /**
     * 物流单号
     */
    private String expressCode;

    /**
     * 物流企业id
     */
    private Long companyId;

    /**
     * 运输方式
     */
    private TransportType transportType;

    /**
    * 运输方式描述
    */
    @TableField(exist = false)
    private String transportTypeDesc;

    public String getTransportTypeDesc() {
        return transportType == null ? null : transportType.getDesc();
    }

    /**
     * 省
     */
    private Long province;

    /**
     * 市
     */
    private Long city;

    /**
     * 目标仓库
     */
    private Long inWarehouseId;

    /**
     * 出入库作业单id
     */
    private Long jobId;
    /**
     * 目标仓库名称
     */
    private String inWarehouseName;
    /**
     * 目标仓库库区
     */
    private String inAreaName;

    /**
     * 运输公司
     */
    private String transportCompany;
}
